package apIExercise.object;

public class Object {
    public static void main(String[] args) {
        String s1 = new String("hello");
        String s2 = new String("hello");
        //String类重写了equals()来比较字符串内容是否相同
        System.out.println(s1.equals(s2));//true 内容相同
        System.out.println(s1 == s2);//==比较的是地址 false

        StringBuilder builder1 = new StringBuilder("hello");
        StringBuilder builder2 = new StringBuilder("hello");
        //StringBuilder没有重写equals()
        System.out.println(builder1.equals(builder2));//false
        System.out.println(builder1 == builder2);//false ==比较的是地址

        System.out.println(s1.equals(builder1));//false  因为类型不同所以equals一定是false
        //System.out.println(s1==builder1);编译错误不是相同类型
//        Point p1 = new Point(200, 500);
//        Point p2 = new Point(200, 500);
//        System.out.println(p1 == p2);//false ==比较的是地址
//        System.out.println(p1.equals(p2));//false equals没有被重写

        Integer i1=new Integer(5);
        Integer i2=new Integer(5);
        System.out.println(i1==i2);//false ==比较的是地址
        System.out.println(i1.equals(i2));//true 包装类重写了equals

        Integer i3=Integer.valueOf(5);
        Integer i4=Integer.valueOf(5);
        System.out.println(i3==i4);//ture valueOf(-128-127)直接复用
        System.out.println(i3.equals(i4));//true 包装类重写equals()比较值了

        int i=i4.intValue();
        System.out.println(i);

        int max=Integer.MAX_VALUE;
        int min=Integer.MIN_VALUE;
        System.out.println("long的最大值为:"+max+"，最小值为:"+min);
        double max1=Double.MAX_VALUE;
        double min1=Double.MIN_VALUE;
        System.out.println("long的最大值为:"+max1+"，最小值为:"+min1);
        long max2=Long.MAX_VALUE;
        long min2=Long.MIN_VALUE;
        System.out.println("long的最大值为:"+max2+"，最小值为:"+min2);

        String a1="39";
        int age=Integer.parseInt(a1);
        System.out.println(age);

        String a2="123.456";
        double price=Double.parseDouble(a2);
        System.out.println(price);

        Integer b=5;
        int j=i;
        System.out.println(j);
    }

}
